home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
doom
/
suckmods.zip
/
SUCKMODS.ZIP
/
suck05
/
src
/
id.qc
< prev
next >
Wrap
Text File
|
1997-05-09
|
3KB
|
106 lines
// Identify the player you are pointed towards
// By Suck (Nat Friedman)
// This code falls under the GNU public license, and cannot be
// redistributed without my name attached.
// This is called with the player who wants to know whose in front
// of him as "self." I call it with an impulse in weapons.qc
entity(float disp) identify_player =
{
// e is a temp entity; guy is our current best guess
// as to at whom the player is pointing
local entity e, guy;
// The best "closeness" heuristic so far.
local float closeness = -1;
// Temp vars.
local vector diff, point;
local float currclose;
local string s1, s2, s3;
// Walk the list of players...
e=find(world, classname, "player");
while (e!=world)
{
// Get a vector pointing from the viewer to the current
// player under consideration
diff=e.origin - self.origin;
// Normalize it since we only care where he's pointing,
// not how far away the guy is.
diff=normalize(diff);
// Normalize self.angles so we can do a length-independent
// consideration
point=normalize(self.angles);
// Find the different between the current player's angle
// and the viewer's vision angle
diff=diff - point;
// The length is going to be our definition of closeness
currclose=vlen(diff);
traceline(self.origin, e.origin, FALSE, self);
if (trace_ent == e)
{
if (closeness == -1)
{
closeness = currclose;
guy = e;
}
else if (currclose < closeness)
{
closeness = currclose;
guy = e;
}
}
e=find(e, classname, "player");
}
// Now we display.
if (disp==0)
return guy;
self.status_time=time+1.75;
if (guy == world)
{
centerprint(self, "You're not looking at anyone!\n");
return world;
}
if (guy.team == self.team)
{
if (guy.weapon == IT_AXE)
s1="Axe, ";
else if (guy.weapon == IT_HOOK)
s1="Hook, ";
else if (guy.weapon == IT_SHOTGUN)
s1="Shot, ";
else if (guy.weapon == IT_SUPER_SHOTGUN)
s1="DblBrl, ";
else if (guy.weapon == IT_NAILGUN)
s1="Nailgun,";
else if (guy.weapon == IT_SUPER_NAILGUN)
s1="S.Nailgun, ";
else if (guy.weapon == IT_GRENADE_LAUNCHER)
s1="Grenade, ";
else if (guy.weapon == IT_ROCKET_LAUNCHER)
s1="Rocket, ";
else if (guy.weapon == IT_LIGHTNING)
s1="TBolt, ";
s2=ftos(guy.health);
if (guy.items&IT_ARMOR1)
s3="Green, ";
else if (guy.items&IT_ARMOR2)
s3="Yellow, ";
else if (guy.items&IT_ARMOR3)
s3="Red, ";
else s3="No Armor";
centerprint7(self, guy.netname, ": ", s1, s3, "Health: ", s2, "\n");
}
else
centerprint3(self, "You are looking at ", guy.netname, "\n");
return guy;
};